<?php

namespace Mogod\Core\MethodBroker;

require_once __DIR__ . '/MethodBrokerAbstract.php';

/**
 *
 * Стандартный брокер методов
 *
 * @author goorus, morph
 *
 */
class MethodBrokerStandart extends MethodBrokerAbstract
{

	/**
	 *
	 * @var object
	 */
	protected $object;

	/**
	 *
	 * @var string
	 */
	protected $method = null;

	/**
	 *
	 * @return string
	 */
	public function getMethod()
	{
		return $this->method;
	}

	/**
	 *
	 * @return object
	 */
	public function getObject()
	{
		return $this->object;
	}

	/**
	 * @inheritdoc
	 */
	public function call($object, $method, array $args)
	{
		$exec = $this->method ?: $method;
		return $this->object->$exec($object, $method, $args);
	}

	/**
	 *
	 * @param string $method
	 * @return $this
	 */
	public function setMethod($method)
	{
		$this->method = $method;
		return $this;
	}

	/**
	 *
	 * @param object $object
	 * @return $this
	 */
	public function setObject($object)
	{
		$this->object = $object;
		return $this;
	}

}
